<template>
  <div class="user-center">
    <front-header :user-info="userInfo"></front-header>

    <!-- 背景装饰 -->
    <div class="bg-decoration">
      <div class="circle circle-1"></div>
      <div class="circle circle-2"></div>
      <div class="circle circle-3"></div>
      <div class="leaf leaf-1"></div>
      <div class="leaf leaf-2"></div>
    </div>

    <div class="main-content">
      <!-- 页面标题 -->
      <div class="page-header">
        <h2>个人中心</h2>
      </div>

      <div class="content-wrapper">
        <!-- 左侧导航 -->
        <div class="side-menu">
          <el-menu :default-active="activeMenu" class="menu-list" @select="handleMenuSelect">
            <el-menu-item index="info">
              <i class="el-icon-user"></i>
              <span>个人信息</span>
            </el-menu-item>
            <el-menu-item index="address">
              <i class="el-icon-location"></i>
              <span>收货地址</span>
            </el-menu-item>
            <el-menu-item index="password">
              <i class="el-icon-lock"></i>
              <span>修改密码</span>
            </el-menu-item>
            <el-menu-item index="balance">
              <i class="el-icon-wallet"></i>
              <span>余额管理</span>
            </el-menu-item>
          </el-menu>
        </div>

        <!-- 右侧内容区 -->
        <div class="content-area">
          <!-- 个人信息 -->
          <div v-if="activeMenu === 'info'" class="info-section">
            <div class="section-header">
              <h3>个人信息</h3>
              <p class="section-desc">您可以在这里修改您的个人信息</p>
            </div>
            <el-form :model="userInfo" :rules="rules" ref="userForm" label-width="100px" class="user-form">
              <!-- 头像上传区域 - 改进版 -->
              <el-form-item label="头像">
                <div class="avatar-upload">
                  <input
                      type="file"
                      ref="avatarFileInput"
                      style="display: none"
                      accept="image/jpeg,image/png"
                      @change="handleAvatarFileChange"
                  >
                  <div v-if="tempAvatar" class="preview-container">
                    <img :src="'/api' + tempAvatar" class="avatar-image">
                    <div class="image-overlay">
                      <el-button type="text" @click="triggerAvatarUpload">重新上传</el-button>
                      <el-button type="text" class="delete-btn" @click="removeAvatar">删除</el-button>
                    </div>
                  </div>
                  <el-button v-else type="primary" @click="triggerAvatarUpload" size="small">
                    <i class="el-icon-upload2"></i> 点击上传
                  </el-button>
                  <div class="el-upload__tip">只能上传jpg/png文件，且不超过2MB</div>
                </div>
              </el-form-item>

              <el-form-item label="用户名" prop="username">
                <el-input v-model="userInfo.username" disabled></el-input>
              </el-form-item>
              <el-form-item label="真实姓名" prop="name">
                <el-input v-model="userInfo.name"></el-input>
              </el-form-item>
              <el-form-item label="邮箱" prop="email">
                <el-input v-model="userInfo.email"></el-input>
              </el-form-item>
              <el-form-item>
                <el-button type="primary" @click="updateUserInfo">保存修改</el-button>
              </el-form-item>
            </el-form>
          </div>

          <!-- 收货地址 -->
          <div v-if="activeMenu === 'address'" class="address-section">
            <div class="section-header">
              <div class="header-left">
                <h3>收货地址</h3>
                <p class="section-desc">管理您的收货地址信息</p>
              </div>
              <el-button type="primary" @click="showAddressDialog('add')" icon="el-icon-plus">
                新增地址
              </el-button>
            </div>

            <div class="address-list">
              <template v-if="addresses.length === 0">
                <el-empty description="暂无收货地址">
                  <el-button type="primary" @click="showAddressDialog('add')">添加地址</el-button>
                </el-empty>
              </template>

              <template v-else>
                <el-card v-for="address in addresses"
                         :key="address.id"
                         class="address-item"
                         shadow="hover"
                >
                  <div class="address-info">
                    <h4 class="receiver">
                      <span class="name">{{ address.receiver }}</span>
                      <span class="phone">{{ address.phone }}</span>
                      <el-tag v-if="address.isDefault === 1" size="small" type="success">默认地址</el-tag>
                    </h4>
                    <p class="detail">{{ address.address }}</p>
                  </div>
                  <div class="address-actions">
                    <el-button v-if="address.isDefault !== 1" type="text" @click="setDefaultAddress(address.id)">
                      设为默认
                    </el-button>
                    <el-button type="text" icon="el-icon-edit" @click="showAddressDialog('edit', address)">
                      编辑
                    </el-button>
                    <el-button type="text" icon="el-icon-delete" class="delete-btn" @click="deleteAddress(address.id)">
                      删除
                    </el-button>
                  </div>
                </el-card>
              </template>
            </div>
          </div>

          <!-- 修改密码 -->
          <div v-if="activeMenu === 'password'" class="password-section">
            <div class="section-header">
              <h3>修改密码</h3>
              <p class="section-desc">您可以在这里修改您的账号密码</p>
            </div>
            <el-form :model="passwordForm" :rules="passwordRules" ref="passwordForm" label-width="100px" class="user-form">
              <el-form-item label="原密码" prop="oldPassword">
                <el-input v-model="passwordForm.oldPassword" type="password" show-password></el-input>
              </el-form-item>
              <el-form-item label="新密码" prop="newPassword">
                <el-input v-model="passwordForm.newPassword" type="password" show-password></el-input>
              </el-form-item>
              <el-form-item label="确认密码" prop="confirmPassword">
                <el-input v-model="passwordForm.confirmPassword" type="password" show-password></el-input>
              </el-form-item>
              <el-form-item>
                <el-button type="primary" @click="updatePassword">修改密码</el-button>
              </el-form-item>
            </el-form>
          </div>

          <!-- 余额管理 -->
          <div v-if="activeMenu === 'balance'" class="balance-section">
            <div class="section-header">
              <h3>余额管理</h3>
              <p class="section-desc">管理您的账户余额</p>
            </div>
            <div class="balance-card">
              <div class="balance-info">
                <div class="balance-icon">
                  <i class="el-icon-wallet"></i>
                </div>
                <div class="balance-detail">
                  <div class="balance-label">当前余额</div>
                  <div class="balance-value">¥{{ userInfo.balance.toFixed(2) }}</div>
                </div>
              </div>
            </div>
            <div class="recharge-section">
              <h4><i class="el-icon-coin"></i> 充值</h4>
              <el-form :model="rechargeForm" :rules="rechargeRules" ref="rechargeForm" label-width="100px" class="recharge-form">
                <el-form-item label="充值金额" prop="amount">
                  <el-input-number v-model="rechargeForm.amount" :min="1" :step="100"></el-input-number>
                </el-form-item>
                <el-form-item>
                  <el-button type="primary" @click="handleRecharge">立即充值</el-button>
                </el-form-item>
              </el-form>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 地址编辑对话框 -->
    <el-dialog :title="dialogType === 'add' ? '新增地址' : '编辑地址'" :visible.sync="addressDialogVisible" width="500px" :close-on-click-modal="false">
      <el-form :model="addressForm" :rules="addressRules" ref="addressForm" label-width="100px">
        <el-form-item label="收货人" prop="receiver">
          <el-input v-model="addressForm.receiver" placeholder="请输入收货人姓名"></el-input>
        </el-form-item>
        <el-form-item label="手机号码" prop="phone">
          <el-input v-model="addressForm.phone" placeholder="请输入手机号码"></el-input>
        </el-form-item>
        <el-form-item label="详细地址" prop="address">
          <el-input
              type="textarea"
              v-model="addressForm.address"
              placeholder="请输入详细地址，如：xx省xx市xx区xx街道xx号"
              :rows="3"
          ></el-input>
        </el-form-item>
        <el-form-item label="设为默认">
          <el-switch v-model="addressForm.isDefault" :active-value="1" :inactive-value="0"></el-switch>
        </el-form-item>
      </el-form>
      <div slot="footer">
        <el-button @click="addressDialogVisible = false">取消</el-button>
        <el-button type="primary" @click="saveAddress">确定</el-button>
      </div>
    </el-dialog>

    <front-footer></front-footer>
  </div>
</template>

<script>
import FrontHeader from '@/components/front/FrontHeader.vue'
import FrontFooter from '@/components/front/FrontFooter.vue'
import Request from '@/utils/request'
import request from "@/utils/request";

export default {
  name: 'UserCenter',
  components: {
    FrontHeader,
    FrontFooter
  },
  data() {
    return {
      activeMenu: 'info',
      currentUser: JSON.parse(localStorage.getItem('frontUser') || '{}'),
      userInfo: {
        id: null,
        username: '',
        name: '',
        email: '',
        avatar: '',
        balance: 0
      },
      tempAvatar: '', // 临时存储头像修改
      rules: {
        name: [{ required: true, message: '请输入真实姓名', trigger: 'blur' }],
        email: [
          { required: true, message: '请输入邮箱地址', trigger: 'blur' },
          { type: 'email', message: '请输入正确的邮箱地址', trigger: 'blur' }
        ]
      },
      addresses: [],
      addressDialogVisible: false,
      dialogType: 'add',
      addressForm: {
        id: '',
        receiver: '',
        phone: '',
        address: '',
        isDefault: 0
      },
      addressRules: {
        receiver: [
          { required: true, message: '请输入收货人姓名', trigger: 'blur' }
        ],
        phone: [
          { required: true, message: '请输入手机号码', trigger: 'blur' },
          { pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号码', trigger: 'blur' }
        ],
        address: [
          { required: true, message: '请输入详细地址', trigger: 'blur' }
        ]
      },
      passwordForm: {
        oldPassword: '',
        newPassword: '',
        confirmPassword: ''
      },
      passwordRules: {
        oldPassword: [
          { required: true, message: '请输入原密码', trigger: 'blur' }
        ],
        newPassword: [
          { required: true, message: '请输入新密码', trigger: 'blur' },
          { min: 6, message: '密码长度不能少于6位', trigger: 'blur' }
        ],
        confirmPassword: [
          { required: true, message: '请确认密码', trigger: 'blur' },
          { validator: (rule, value, callback) => {
              if (value !== this.passwordForm.newPassword) {
                callback(new Error('两次输入的密码不一致'));
              } else {
                callback();
              }
            }, trigger: 'blur' }
        ]
      },
      rechargeForm: {
        amount: 100
      },
      rechargeRules: {
        amount: [
          { type: 'number', min: 1, message: '充值金额必须大于0', trigger: 'blur' }
        ]
      },
      loading: false, // 上传加载状态
      apiBaseUrl: process.env.VUE_APP_API_BASE_URL || 'http://localhost:3000' // 后端API基础URL
    }
  },
  created() {
    const userInfo = localStorage.getItem('frontUser')
    if(!userInfo){
      this.$message.warning('请先登录')
      this.$router.push('/login')
    }
    else{
      this.userInfo = JSON.parse(userInfo)
      this.tempAvatar = this.userInfo.avatar; // 初始化临时头像
      this.getUserInfo()
      this.getAddresses()
    }
  },

  methods: {
    handleMenuSelect(index) {
      this.activeMenu = index;
    },
    async getUserInfo() {
      try {
        const userId = this.currentUser.id
        const res = await Request.get(`/user/${userId}`)
        if (res.code === '0') {
          this.userInfo = res.data
          this.tempAvatar = this.userInfo.avatar; // 更新临时头像
          // 更新本地存储的用户信息，包括头像
          localStorage.setItem('frontUser', JSON.stringify(res.data))
        }
      } catch (error) {
        console.error('获取用户信息失败:', error)
        this.$message.error('获取用户信息失败')
      }
    },

    async updateUserInfo() {
      try {
        this.$refs.userForm.validate(async (valid) => {
          if (valid) {
            if (this.tempAvatar !== this.userInfo.avatar) {
              this.userInfo.avatar = this.tempAvatar;
            }
            const res = await Request.put(`/user/${this.userInfo.id}`, this.userInfo)
            if (res.code === '0') {
              this.$message.success('个人信息更新成功')
              // 更新本地存储的用户信息
              localStorage.setItem('frontUser', JSON.stringify(res.data))
            }
          }
        })
      } catch (error) {
        console.error('更新用户信息失败:', error)
        this.$message.error('更新用户信息失败')
      }
    },

    // 头像上传相关方法 - 改进版
    triggerAvatarUpload() {
      this.$refs.avatarFileInput.click();
    },

    async handleAvatarFileChange(e) {
      const file = e.target.files[0];
      if (!file) return;

      // 验证文件类型和大小
      const isJPGOrPNG = file.type === 'image/jpeg' || file.type === 'image/png';
      const isLt2M = file.size / 1024 / 1024 < 2;

      if (!isJPGOrPNG) {
        this.$message.error('只能上传 JPG/PNG 格式的图片!');
        return;
      }
      if (!isLt2M) {
        this.$message.error('图片大小不能超过 2MB!');
        return;
      }

      // 创建 FormData
      const formData = new FormData();
      formData.append('file', file);

      this.loading = true;
      try {
        const res = await request.post('/file/upload/img', formData, {
          headers: {
            'Content-Type': 'multipart/form-data'
          }
        });

        if (res.code === '0') {
          // 直接使用后端返回的相对路径
          this.tempAvatar = res.data;
          this.$message.success('头像已选择，点击保存修改生效');
        } else {
          this.$message.error(res.msg || '头像上传失败');
        }
      } catch (error) {
        console.error('头像上传失败:', error);
        this.$message.error('头像上传失败');
      } finally {
        this.loading = false;
      }
    },

    removeAvatar() {
      this.$confirm('确认删除头像?', '提示', {
        type: 'warning'
      }).then(() => {
        this.tempAvatar = '';
        this.$message.success('头像已删除，点击保存修改生效');
      }).catch(() => {});
    },

    async getAddresses() {
      try {
        const userId = this.currentUser.id
        const res = await Request.get(`/address/user/${userId}`)
        if (res.code === '0') {
          this.addresses = res.data||[]
        }
      } catch (error) {
        console.error('获取地址列表失败:', error)
        this.$message.error('获取地址列表失败')
      }
    },

    showAddressDialog(type, address) {
      this.dialogType = type
      this.addressDialogVisible = true
      if (type === 'edit' && address) {
        this.addressForm = {
          id: address.id,
          receiver: address.receiver,
          phone: address.phone,
          address: address.address,
          isDefault: address.isDefault
        }
      } else {
        this.addressForm = {
          receiver: '',
          phone: '',
          address: '',
          isDefault: 0
        }
      }
    },

    async saveAddress() {
      try {
        await this.$refs.addressForm.validate()
        const userId = this.currentUser.id
        const addressData = {
          ...this.addressForm,
          userId,
        }

        if (this.dialogType === 'add') {
          const res = await Request.post('/address', addressData)
          if (res.code === '0') {
            this.$message.success('添加地址成功')
            this.getAddresses()
          }
        } else {
          const res = await Request.put(`/address/${addressData.id}`, addressData)
          if (res.code === '0') {
            this.$message.success('更新地址成功')
            this.getAddresses()
          }
        }
        this.addressDialogVisible = false
      } catch (error) {
        console.error('保存地址失败:', error)
        this.$message.error('保存地址失败')
      }
    },

    async setDefaultAddress(id) {
      try {
        const res = await Request.put(`/address/${id}/default`)
        if (res.code === '0') {
          this.$message.success('设置默认地址成功')
          this.getAddresses()
        }
      } catch (error) {
        console.error('设置默认地址失败:', error)
        this.$message.error('设置默认地址失败')
      }
    },

    async deleteAddress(id) {
      try {
        await this.$confirm('确定要删除该地址吗？', '提示', {
          type: 'warning'
        })
        const res = await Request.delete(`/address/${id}`)
        if (res.code === '0') {
          this.$message.success('删除地址成功')
          this.getAddresses()
        }
      } catch (error) {
        if (error !== 'cancel') {
          console.error('删除地址失败:', error)
          this.$message.error('删除地址失败')
        }
      }
    },

    async updatePassword() {
      try {
        this.$refs.passwordForm.validate(async (valid) => {
          if (valid) {
            const userId = this.currentUser.id
            const params = {
              newPassword: this.passwordForm.newPassword,
              oldPassword: this.passwordForm.oldPassword
            }
            const res = await Request.put(`/user/password/${userId}`, params)
            if (res.code === '0') {
              this.$message.success('密码修改成功')
              this.passwordForm = {
                oldPassword: '',
                newPassword: '',
                confirmPassword: ''
              }
              this.$refs.passwordForm.resetFields()
            } else {
              this.$message.error(res.msg || '密码修改失败')
            }
          }
        })
      } catch (error) {
        console.error('修改密码失败:', error)
        this.$message.error('修改密码失败')
      }
    },

    async handleRecharge() {
      try {
        await this.$refs.rechargeForm.validate()

        const userId = this.userInfo.id
        const amount = this.rechargeForm.amount

        const res = await Request.post(`/user/balance/recharge/${userId}?amount=${amount}`)

        if (res.code === '0') {
          // 更新用户余额
          this.userInfo.balance = res.data

          // 更新本地存储的用户信息
          const updatedUser = {...this.currentUser, balance: res.data}
          localStorage.setItem('frontUser', JSON.stringify(updatedUser))

          this.$message.success(`成功充值 ¥${amount.toFixed(2)}`)

          // 重置充值金额
          this.rechargeForm.amount = 100
        } else {
          this.$message.error(res.msg || '充值失败')
        }
      } catch (error) {
        console.error('充值失败:', error)
        this.$message.error('充值失败')
      }
    }
  }
}
</script>

<style scoped>
/* 样式部分保持不变，仅修改了逻辑部分 */
.user-center {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(135deg, #fff8e1 0%, #fff3e0 100%);
  position: relative;
  overflow: hidden;
}

/* 背景装饰 */
.bg-decoration {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.circle {
  position: absolute;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(255, 152, 0, 0.1), rgba(255, 193, 7, 0.05));
}

.circle-1 {
  width: 600px;
  height: 600px;
  top: -200px;
  right: -100px;
}

.circle-2 {
  width: 400px;
  height: 400px;
  bottom: -100px;
  left: -100px;
}

.circle-3 {
  width: 300px;
  height: 300px;
  top: 40%;
  right: 10%;
  background: linear-gradient(135deg, rgba(255, 193, 7, 0.05), rgba(255, 152, 0, 0.08));
}

.leaf {
  position: absolute;
  background-color: rgba(255, 152, 0, 0.1);
  border-radius: 50% 0;
  transform: rotate(45deg);
}

.leaf-1 {
  width: 200px;
  height: 200px;
  bottom: 10%;
  right: 5%;
}

.leaf-2 {
  width: 150px;
  height: 150px;
  top: 20%;
  left: 5%;
  transform: rotate(-30deg);
}

.main-content {
  flex: 1;
  padding: 32px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
  position: relative;
  z-index: 2;
}

/* 页面标题样式 */
.page-header {
  margin-bottom: 24px;
  padding: 20px 24px;
  border-radius: 16px;
  position: relative;
  overflow: hidden;
}

.page-header h2 {
  font-size: 28px;
  font-weight: 600;
  color: #F57C00;
  margin: 0;
  position: relative;
  padding-left: 16px;
}

.page-header h2::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 28px;
  background: linear-gradient(to bottom, #FF9800, #FFC107);
  border-radius: 2px;
}

.content-wrapper {
  display: flex;
  gap: 24px;
}

/* 左侧菜单样式 */
.side-menu {
  width: 240px;
  background: white;
  border-radius: 16px;
  border: 1px solid rgba(255, 193, 7, 0.1);
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.menu-list {
  border-right: none;
}

.menu-list .el-menu-item {
  height: 56px;
  line-height: 56px;
  font-size: 15px;
  transition: all 0.3s ease;
  border-left: 3px solid transparent;
}

.menu-list .el-menu-item:hover {
  background: rgba(255, 193, 7, 0.05);
  color: #FF9800;
}

.menu-list .el-menu-item.is-active {
  background: rgba(255, 193, 7, 0.1);
  color: #FF9800;
  border-left: 3px solid #FF9800;
}

.menu-list .el-menu-item i {
  font-size: 18px;
  margin-right: 12px;
  color: #909399;
}

.menu-list .el-menu-item.is-active i {
  color: #FF9800;
}

/* 右侧内容区样式 */
.content-area {
  flex: 1;
  background: white;
  border-radius: 16px;
  border: 1px solid rgba(255, 193, 7, 0.1);
  padding: 30px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 193, 7, 0.1);
}

.section-header h3,
.header-left h3 {
  font-size: 24px;
  color: #F57C00;
  margin: 0 0 8px 0;
  font-weight: 500;
  position: relative;
}

.section-desc {
  color: #606266;
  font-size: 14px;
  margin: 0;
}

/* 表单样式 */
.user-form {
  max-width: 500px;
  background: rgba(255, 193, 7, 0.02);
  padding: 24px;
  border-radius: 12px;
  border: 1px solid rgba(255, 193, 7, 0.05);
}

/* 头像上传样式 */
.avatar-upload {
  text-align: center;
  margin-bottom: 24px;
}

.preview-container {
  position: relative;
  display: inline-block;
  width: 120px;
  height: 120px;
  margin: 0 auto 10px;
}

.avatar-image {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border: 1px solid rgba(255, 193, 7, 0.2);
  border-radius: 50%;
  transition: all 0.3s;
  background-color: rgba(255, 193, 7, 0.05);
}

.image-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: all 0.3s;
  border-radius: 50%;
  flex-direction: column;
  gap: 10px;
}

.preview-container:hover .image-overlay {
  opacity: 1;
}

.image-overlay .el-button {
  color: #fff;
  margin: 0 10px;
  padding: 6px 12px;
  font-size: 12px;
}

.image-overlay .delete-btn {
  color: #f56c6c;
}

.el-upload__tip {
  font-size: 12px;
  color: #909399;
  margin-top: 5px;
  line-height: 1.5;
}

/* 地址列表样式 */
.address-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.address-item {
  transition: all 0.3s ease;
  border: 1px solid rgba(255, 193, 7, 0.1);
  border-radius: 12px;
  position: relative;
  overflow: hidden;
}

.address-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 16px rgba(255, 152, 0, 0.08);
}

.address-info {
  flex: 1;
}

.receiver {
  margin: 0 0 12px 0;
  display: flex;
  align-items: center;
  gap: 16px;
}

.name {
  font-size: 16px;
  font-weight: 600;
  color: #F57C00;
}

.phone {
  color: #606266;
  font-weight: normal;
}

.detail {
  color: #606266;
  margin: 0;
  line-height: 1.5;
}

.address-actions {
  margin-top: 16px;
  display: flex;
  gap: 16px;
  border-top: 1px dashed rgba(255, 193, 7, 0.1);
  padding-top: 16px;
}

.address-actions .el-button {
  padding: 8px 12px;
}

.address-actions .el-button--text {
  color: #FF9800;
}

.delete-btn {
  color: #f56c6c !important;
}

/* 按钮样式 */
.el-button--primary {
  background: linear-gradient(135deg, #FF9800, #FFC107);
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 8px rgba(255, 152, 0, 0.15);
}

.el-button--primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(255, 152, 0, 0.2);
}

.el-button--primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(255, 152, 0, 0.15);
}

/* 对话框样式 */
:deep(.el-dialog) {
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

:deep(.el-dialog__header) {
  padding: 20px;
  border-bottom: 1px solid rgba(255, 193, 7, 0.1);
  margin: 0;
  background: linear-gradient(135deg, rgba(255, 152, 0, 0.02), rgba(255, 193, 7, 0.05));
}

:deep(.el-dialog__title) {
  color: #F57C00;
  font-weight: 600;
  font-size: 18px;
}

:deep(.el-dialog__body) {
  padding: 24px;
  max-height: 60vh;
  overflow-y: auto;
}

/* 自定义滚动条样式 */
:deep(.el-dialog__body::-webkit-scrollbar) {
  width: 6px;
}

:deep(.el-dialog__body::-webkit-scrollbar-thumb) {
  background: rgba(255, 152, 0, 0.3);
  border-radius: 3px;
}

:deep(.el-dialog__body::-webkit-scrollbar-track) {
  background: transparent;
}

:deep(.el-dialog__footer) {
  padding: 16px 24px;
  border-top: 1px solid rgba(255, 193, 7, 0.1);
  margin-top: 0;
  background: rgba(255, 193, 7, 0.02);
}

/* 表单项样式 */
:deep(.el-form-item) {
  margin-bottom: 24px;
}

:deep(.el-input__inner),
:deep(.el-textarea__inner) {
  border-radius: 8px;
  transition: all 0.3s ease;
  border-color: rgba(255, 193, 7, 0.2);
}

:deep(.el-input__inner:hover),
:deep(.el-textarea__inner:hover) {
  border-color: #FFC107;
}

:deep(.el-input__inner:focus),
:deep(.el-textarea__inner:focus) {
  border-color: #FF9800;
  box-shadow: 0 0 0 2px rgba(255, 152, 0, 0.1);
}

:deep(.el-form-item__label) {
  color: #F57C00;
  font-weight: 500;
}

/* 空状态样式 */
:deep(.el-empty) {
  padding: 40px 0;
}

:deep(.el-empty__image) {
  width: 120px;
  height: 120px;
}

:deep(.el-empty__description) {
  color: #606266;
  margin-top: 16px;
  margin-bottom: 16px;
}

:deep(.el-empty .el-button--primary) {
  background: linear-gradient(135deg, #FF9800, #FFC107);
  border: none;
  transition: all 0.3s ease;
  padding: 12px 24px;
  font-size: 15px;
}

:deep(.el-empty .el-button--primary:hover) {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(255, 152, 0, 0.2);
}

/* 标签样式 */
:deep(.el-tag--success) {
  background-color: rgba(255, 152, 0, 0.1);
  border-color: rgba(255, 152, 0, 0.2);
  color: #FF9800;
}

/* 密码表单样式 */
.password-section {
  width: 100%;
}

.password-section .user-form {
  position: relative;
  overflow: hidden;
}

.password-section .user-form::before {
  content: '';
  position: absolute;
  top: -80px;
  right: -80px;
  width: 160px;
  height: 160px;
  background: rgba(255, 193, 7, 0.05);
  border-radius: 50%;
  z-index: 0;
}

.password-section .user-form::after {
  content: '';
  position: absolute;
  bottom: -60px;
  left: -60px;
  width: 120px;
  height: 120px;
  background: rgba(255, 152, 0, 0.03);
  border-radius: 50%;
  z-index: 0;
}

.password-section .el-form-item {
  position: relative;
  z-index: 1;
}

/* 余额管理样式 */
.balance-section {
  width: 100%;
}

.balance-card {
  margin-bottom: 30px;
  border-radius: 16px;
  overflow: hidden;
  transition: all 0.3s ease;
  border: 1px solid rgba(255, 193, 7, 0.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.balance-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(255, 152, 0, 0.1);
}

.balance-info {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 24px;
  background: linear-gradient(135deg, rgba(255, 152, 0, 0.02), rgba(255, 193, 7, 0.05));
}

.balance-icon {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FF9800, #FFC107);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(255, 152, 0, 0.2);
}

.balance-icon i {
  font-size: 32px;
  color: white;
}

.balance-detail {
  flex: 1;
}

.balance-label {
  font-size: 16px;
  color: #606266;
  margin-bottom: 8px;
}

.balance-value {
  font-size: 32px;
  font-weight: 600;
  color: #FF9800;
  text-shadow: 0 1px 2px rgba(255, 152, 0, 0.1);
}

.recharge-section {
  background: rgba(255, 193, 7, 0.05);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 30px;
  border: 1px solid rgba(255, 193, 7, 0.1);
  position: relative;
  overflow: hidden;
}

.recharge-section h4 {
  font-size: 18px;
  color: #F57C00;
  margin: 0 0 20px 0;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.recharge-section h4::before {
  content: '';
  width: 4px;
  height: 18px;
  background: linear-gradient(to bottom, #FF9800, #FFC107);
  border-radius: 2px;
}

.recharge-form {
  max-width: 500px;
  position: relative;
  z-index: 1;
}

.recharge-form :deep(.el-input-number) {
  width: 240px !important;
}
</style>